﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ColorWanted.Plugin.Base64Converter
{
    public partial class Base64ConverterForm : Form
    {
        public Base64ConverterForm()
        {
            InitializeComponent();
        }

        private void lkClearClearText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            tbClear.Clear();
        }

        private void lkClearBases64_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            tbBase64.Clear();
        }

        private void btnToBase64_Click(object sender, EventArgs e)
        {
            var text = tbClear.Text;
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            tbBase64.Text = Convert.ToBase64String(Encoding.UTF8.GetBytes(text));
        }

        private void btnToClear_Click(object sender, EventArgs e)
        {
            var text = tbBase64.Text;
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            tbClear.Text = Encoding.UTF8.GetString(Convert.FromBase64String(text));
        }
    }
}
